<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Creates a new image</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="imagick.negateimage.html">Imagick::negateImage</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="imagick.newpseudoimage.html">Imagick::newPseudoImage</a></div>
 <div class="up"><a href="class.imagick.html">Imagick</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="imagick.newimage" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Imagick::newImage</h1>
  <p class="verinfo">(PECL imagick 2.0.0)</p><p class="refpurpose"><span class="refname">Imagick::newImage</span> &mdash; <span class="dc-title">Creates a new image</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-imagick.newimage-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>Imagick::newImage</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$cols</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$rows</code></span>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$background</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$format</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   Creates a new image and associates ImagickPixel value as background color
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-imagick.newimage-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">cols</code></em></dt>

     <dd>

      <p class="para">
      Columns in the new image
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">rows</code></em></dt>

     <dd>

      <p class="para">
      Rows in the new image
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">background</code></em></dt>

     <dd>

      <p class="para">
      The background color used for this image
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">format</code></em></dt>

     <dd>

      <p class="para">
      Image format. This parameter was added in Imagick version 2.0.1.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-imagick.newimage-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-imagick.newimage-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   错误时抛出 ImagickException。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-imagick.newimage-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>2.1.0</td>
       <td>
        Now allows a string representing the color as the third parameter.
        Previous versions allow only an ImagickPixel object.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-imagick.newimage-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3237">
    <p><strong>Example #1 Using <span class="function"><strong>Imagick::newImage()</strong></span>:</strong></p>
    <div class="example-contents"><p>
     Create a new image and display it.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$image&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Imagick</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$image</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">newImage</span><span style="color: #007700">(</span><span style="color: #0000BB">100</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">,&nbsp;new&nbsp;</span><span style="color: #0000BB">ImagickPixel</span><span style="color: #007700">(</span><span style="color: #DD0000">'red'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$image</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setImageFormat</span><span style="color: #007700">(</span><span style="color: #DD0000">'png'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type:&nbsp;image/png'</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$image</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="imagick.negateimage.html">Imagick::negateImage</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="imagick.newpseudoimage.html">Imagick::newPseudoImage</a></div>
 <div class="up"><a href="class.imagick.html">Imagick</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
